#include "CPlayerBoltedState.h"
#include "CPlayer.h"
#include "CTimer.h"
#include "CPlayerIdleState.h"
#include "CCloud.h"
#include "CChangeBackground.h"
#include "CSGD_FModManager.h"
#include "CGamePlayState.h"
#include "testenum.h"

CPlayerBoltedState::CPlayerBoltedState()
{
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(Shocked));
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(Shocked));
	m_vAnimations.push_back(CAnimationEngine::GetInstance()->LoadAnimation(Shocked));
}

CPlayerBoltedState *CPlayerBoltedState::GetInstance()
{
	static CPlayerBoltedState Instance;
	return &Instance;
}

void CPlayerBoltedState::Enter(CPlayer *pPlayer)
{
	m_pPlayer = pPlayer;
	m_pPlayer->m_unTimePeriod++;
	m_pPlayer->m_pCloud->m_unCurrState = BOLT;
	CChangeBackground::GetInstance()->IncrementBackground();
#if LOADSFX
	CSGD_FModManager::GetInstance()->StopSound( CGamePlayState::GetInstance()->m_nSFX[ CGamePlayState::GetInstance()->THUNDER_SFX ] );
CSGD_FModManager::GetInstance()->PlaySound( CGamePlayState::GetInstance()->m_nSFX[ CGamePlayState::GetInstance()->THUNDER_SFX ] );
CSGD_FModManager::GetInstance()->SetVolume( CGamePlayState::GetInstance()->m_nSFX[ CGamePlayState::GetInstance()->THUNDER_SFX ], 0.3f );
#endif LOADSFX
}

void CPlayerBoltedState::Run()
{
	m_pPlayer->m_Vel.Zero();
	if (!m_vAnimations[m_pPlayer->m_unTimePeriod]->Play(CTimer::GetInstance()->GetElapsedTime()))
	{
		m_pPlayer->m_pCloud->m_unCurrState = IDLE;
		m_pPlayer->ChangeState(CPlayerIdleState::GetInstance());
	}
}

void CPlayerBoltedState::Exit()
{
}